package xia.wan.glowingterms.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import xia.wan.glowingterms.service.SendMailservice;
import xia.wan.glowingterms.service.impl.SendMail;

import javax.annotation.Resource;

/**
 * @PACKAGE_NAME: xia.wan.glowingterms.config
 * @AUTHOR: 太白
 * @DATE: 2022/12/01/19:05
 **/
@Configuration      //主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 开启定时任务
public class ScheduleTask {

    @Resource
    SendMailservice mailservice;
    //添加定时任务
    @Async
    @Scheduled(cron = "0 */1 * * * ?")//每分钟发一次
    /**
     * 定时发送小情话
     */
    public void sendLove(){
        mailservice.sendLovePrattle();
    }

/*    @Async
    @Scheduled(cron = "0 0 7 * * ?")//每天7点运行一次
    *//**
     * 定时发送天气
     *//*
    public void sendWeather(){
//      实时天气
        sendMail.sendWeather();
    }*/
}
